#include "bullet.h"

Bullet::Bullet(QObject *parent)
{

}
Bullet::Bullet(QPoint _pos,QPixmap _pixmap,int _type,int dirc)
{
    this->setPos(_pos);
    this->setPixmap(_pixmap);
    this->mBulletType= _type;
    mSpeed=2;
    this->setScale(0.5);//子弹缩放
    toward=dirc;
}

void Bullet::BulletMove()
{
    QPoint _dir;
    switch(toward)
    {
        case 1: _dir=QPoint(0,-1);  break;
        case 2: _dir=QPoint(0,1);  break;
        case 3: _dir=QPoint(-1,0);  break;
        case 4: _dir=QPoint(1,0);  break;
    default: break;
    }
    this->moveBy(_dir.x()*mSpeed, _dir.y()*mSpeed);
}
